import time

import pyautogui

# 1、持续点击左键
# 2、鼠标移动取消连续点击，休眠 1s 后，继续 1 步骤
while True:
    # 获取鼠标当前位置
    out_x, out_y = pyautogui.position()
    print(f"外循环，当前鼠标位置: ({out_x}, {out_y})")
    move = True
    while move:
        in_x, in_y = pyautogui.position()
        move = out_x == in_x and out_y == in_y
        print(f"内循环，当前鼠标位置: ({in_x}, {in_y})？鼠标是否有移动？{move}")
        if move:
            pyautogui.click(in_x, in_y)
        # 休眠 0.1 秒
        time.sleep(0.01)
    # 休眠5s后继续连续点击
    time.sleep(1)
